package com.jeasonzhao.commons.logger;

public class Log4JListener implements LogListener
{
    private org.apache.commons.logging.Log log = null;

    public Log4JListener(Class<?> cls)
    {
        log = org.apache.commons.logging.LogFactory.getLog(cls == null ? Log4JListener.class : cls);
    }

    public void log(LogLevel logLevel,String strMessage,Throwable excep)
    {
        switch(logLevel)
        {
            case SYSTEM:
            case INFO:
                log.info(strMessage,excep);
                break;
            case FATAL:
                log.fatal(strMessage,excep);
                break;
            case ERROR:
                log.error(strMessage,excep);
                break;
            case WARN:
                log.warn(strMessage,excep);
                break;
            case DEBUG:
                log.debug(strMessage,excep);
                break;
            default:
                log.info(strMessage,excep);
                break;
        }
    }
}
